<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>R计算器 v1.0 - by 呵Sever</title>
<style type="text/css">
	.result{
	}
	.result th, .result td{
		border: 1px solid #aaa;
		padding:0 5px;
		text-align: right;
	}
</style>

<script type="text/javascript">
function getRandomNum(Min,Max,scope){   
	var number = (Min+Math.random()*(Max-Min));
	return number.toFixed(scope);
}   

function cal(){
	var x = document.getElementById("x").value;
	var y = document.getElementById("y").value;
	var z = document.getElementById("z").value;
	var lineCount = document.getElementById("lineCount").value;
	
	var scope = document.getElementById("scope").value;
	var aMax = document.getElementById("aMax").value;
	aMax = parseFloat(aMax);   
	var aMin = document.getElementById("aMin").value;
	aMin = parseFloat(aMin);   
	
	var result = document.getElementById("result")
    
	result.innerHTML="<tr><th>R</th><th>z</th><th>x</th><th>a</th><th>y</th><th>b</th><th>R = z - x*a - y*b</th></tr>";
	for(var i=0; i<lineCount; i++){
		var R = getRandomNum(-0.001,0.001,scope);
		var a = getRandomNum(aMax,aMin,scope);
		var b = -(R-z+a*x)/y;
		var newTr = result.insertRow();
		var newTd0 = newTr.insertCell();
        var newTd1 = newTr.insertCell();
        var newTd2 = newTr.insertCell();
        var newTd3 = newTr.insertCell();
        var newTd4 = newTr.insertCell();
        var newTd5 = newTr.insertCell();
        var newTd6 = newTr.insertCell();
        
        newTd0.innerHTML = R; 
        newTd1.innerHTML = z; 
        newTd2.innerHTML = x; 
        newTd3.innerHTML = a; 
        newTd4.innerHTML = y; 
        newTd5.innerHTML = b;
        newTd6.innerHTML = R+"="+z+"-"+x+"*"+a+"-"+y+"*"+b; 
	}
	
}
</script>
</head>
<body>
	呵Sever网址：<a href="http://www.hosever.com" target="_blank">http://www.hosever.com</a><br/>
	计算：R = z - x*a - y*b<br/>
	<br/>
	x=<input id="x" value="1"/>
	y=<input id="y" value="1"/>
	z=<input id="z" value="1"/><br/>
	a的范围：<input id="aMin" value="-0.1"/>~<input id="aMax" value="0.1"/><br/>
	生成行数：<input id="lineCount" value="10" /><br/>
	R和a的小数位：<input id="scope" value="10" /><br/>
	<button onclick="cal()">生成</button>
	<br/><br/>
	<br/>
	<table id="result" class="result" cellpadding="0" cellspacing="0">
	</table>
	
	
</body>
</html>